<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> JS CheckBox </TITLE>
 <SCRIPT LANGUAGE="JavaScript">
  var i=0,j=0;
  function test(){
   j=0;
   var ckb = document.getElementsByName("tj");
   for(i=0;i<ckb.length;i++){
    if(ckb[i].checked==true){
     j+=1;
    }
    if(j>3){
     alert("最多只能选三个");
     return false;
    }
   }
   alert(j);
  }
 </SCRIPT>
 </HEAD>
 <BODY>
 
   <div><input type="checkbox" name="tj" /> aaaaa </div>
   <div><input type="checkbox" name="tj" /> bbbbb </div>
   <div><input type="checkbox" name="tj" /> ccccc </div>
   <div><input type="checkbox" name="tj" /> ddddd </div>
   <div><input type="checkbox" name="tj" /> eeeee </div>
   <div><input type="checkbox" name="tj" /> fffff </div>
   <div><input type="checkbox" name="tj" /> ggggg </div>
   <input type="button" value="提交" onclick="test()" />
 </BODY>
</HTML>